from django import forms
from django.contrib.auth.models import User
class LoginForm(forms.Form):
    username = forms.CharField()
    password = forms.CharField()
class RegisterForm(forms.ModelForm):
    username = forms.CharField()
    password = forms.CharField()
    password2 = forms.CharField(label="password", widget=forms.PasswordInput)
    class Meta:
        model = User
        fields = ("username","email")
    
    def clean_password2(self):
        cd = self.cleaned_data
        if cd['password'] != cd ['password2']:
            raise forms.ValidationError("passwords do not match")
        return cd['password2']
